package com.wanmait.teatrain.controller;

import com.wanmait.teatrain.entity.Admin;
import com.wanmait.teatrain.service.CourseResourceService;
import com.wanmait.teatrain.utils.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 课程与资源关联表 前端控制器
 * </p>
 *
 * @author wanmait
 * @since 2025-10-22
 */
@RestController
@RequestMapping("/courseResource")
public class CourseResourceController {
    @Resource
    private CourseResourceService courseResourceService;
    //根据课程查资源id
    @GetMapping("selectResourseByCourseId")
    public AjaxResult selectResourseByCourseId(@RequestParam("courseId") Integer courseId, HttpServletRequest servletRequest){
        Admin admin = (Admin) servletRequest.getAttribute("loginEmp");
        Integer adminId = admin.getId();
        System.out.println("进入的员工Id" + adminId);
        return courseResourceService.selectResourseByCourseId(courseId,adminId);
    }

    @GetMapping("selectResource")
    public AjaxResult selectResource(@RequestParam("courseId") Integer courseId){
        return courseResourceService.selectResource(courseId);
    }

}
